//
//  DKOrderNoDataFootView.m
//  DanKU
//
//  Created by EDY on 2023/11/12.
//

#import "DKOrderNoDataFootView.h"
#import "DKUnauthorizedNoRecordView.h"
#import "DKAuthStepViewController.h"

@implementation DKOrderNoDataFootView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame: frame]) {
        self.backgroundColor =  DK_Hex(@"#FAFAFA");
        [self creatUI];
    }
    return self;
}

-(void)productApplyNow{
    DKAuthStepViewController *dk_AuthStepViewCtrl = [[DKAuthStepViewController alloc] init];
    dk_AuthStepViewCtrl.hidesBottomBarWhenPushed = YES;
    [self.viewController.navigationController pushViewController:dk_AuthStepViewCtrl animated:YES];
}

-(void)homeCheckAgreement{
    DKWebViewController * dk_WebViewCtrl = [[DKWebViewController alloc] initWithUrl:DK_PrivacyAgreement withIsNavBar:YES];
    [self.viewController.navigationController pushViewController:dk_WebViewCtrl animated:YES];
}

-(void)creatUI{
    DKUnauthorizedNoRecordView * dkUnauthorizedNoRecordView = [[DKUnauthorizedNoRecordView alloc] init];
    [self addSubview:dkUnauthorizedNoRecordView];
    [dkUnauthorizedNoRecordView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(0)));
        make.right.equalTo(@(-DK_IsWidthScale(0)));
//        make.top.equalTo(dkUnauthorizedProductStepView.mas_bottom).offset(DK_IsWidthScale(78));
        make.top.equalTo(self).offset(22);
        make.height.equalTo(@(DK_IsWidthScale(148)));
    }];
    
    if(![[DKGlobalHelper defaultManager].loanSetpInfoMdl.step isEqualToString:@"100"]){//未认证

        UIButton * dk_ProductStartBtn = [[UIButton alloc] init];
        [dk_ProductStartBtn setTitle:@"Apply now" forState:UIControlStateNormal];
        [dk_ProductStartBtn setTitleColor:DK_Hex(@"#FFFFFF") forState:UIControlStateNormal];
        dk_ProductStartBtn.titleLabel.font = DK_FONT_Semibold(16);
        [dk_ProductStartBtn setBackgroundColor:DK_Hex(@"#4566FF")];
        dk_ProductStartBtn.layer.cornerRadius = DK_IsWidthScale(25);
        [dk_ProductStartBtn addTarget:self action:@selector(productApplyNow) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:dk_ProductStartBtn];
        [dk_ProductStartBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@(DK_IsWidthScale(30)));
            make.right.equalTo(@(-DK_IsWidthScale(30)));
            make.bottom.mas_equalTo(-DK_TabBar_H-17-20);
            make.height.equalTo(@(DK_IsWidthScale(50)));
        }];
    }
    
//    UIButton * dk_ProductAgreementBtn = [[UIButton alloc] init];
//    [dk_ProductAgreementBtn setTitle:@"《Privacy Agreement》" forState:UIControlStateNormal];
//    [dk_ProductAgreementBtn setTitleColor:DK_Hex(@"#CCCCCC") forState:UIControlStateNormal];
//    dk_ProductAgreementBtn.titleLabel.font = DK_FONT_Regular(12);
//    [dk_ProductAgreementBtn addTarget:self action:@selector(homeCheckAgreement) forControlEvents:UIControlEventTouchUpInside];
//    [self addSubview:dk_ProductAgreementBtn];
//    [dk_ProductAgreementBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.equalTo(self);
//        make.bottom.equalTo(self).offset(-DK_TabBar_H);
//        make.height.equalTo(@(DK_IsWidthScale(17)));
//    }];

}

//获取View所在的Viewcontroller方法
- (UIViewController *)viewController {
    for (UIView* next = [self superview]; next; next = next.superview) {
        UIResponder *nextResponder = [next nextResponder];
        if ([nextResponder isKindOfClass:[UIViewController class]]) {
            return (UIViewController *)nextResponder;
        }
    }
    return nil;
}


@end
